home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / mach / sun4c.md / globals.h < prev    next >
C/C++ Source or Header  |  1990-10-12  |  5KB  |  187 lines

  1. /*    @(#)globals.h 1.8 88/02/08 SMI    */
  2.  
  3. /*
  4.  * Copyright (c) 1988 by Sun Microsystems, Inc.
  5.  */
  6.  
  7.     /*    Sparc floating-point simulator PRIVATE include file. */
  8.  
  9. /*
  10.  * This whole file refuses to lint.
  11.  */
  12. #ifndef lint
  13. #include <sys/types.h>
  14. #include "sprite.h"
  15. #include "mach.h"
  16.  
  17. /*
  18.  * A few macro's for unix compatiblity.
  19.  */
  20.  
  21. #define    regs Mach_RegState
  22. #define    r_pc    pc
  23. #define r_npc    nextPc
  24. #define    r_g1    globals[1]
  25. #define    r_o0    ins[0]
  26.  
  27. #define    rwindow    Mach_RegWindow
  28. #define    rw_local locals
  29. #define    rw_in     ins
  30. #define fpu  Mach_RegState
  31. #define fpu_fsr    fsr
  32. #define fpu_regs fregs
  33. #define    _fp_read_pfreg _fp_read_vfreg
  34. #define    _fp_write_pfreg _fp_write_vfreg
  35.  
  36. enum seg_rw {S_WRITE, S_READ};
  37. #define KERNELBASE    0xc0000000
  38.  
  39. #define FPU_REGS_TYPE    unsigned
  40.  
  41. #define FPE_FLTOPERR_TRAP 1
  42. #define FPE_FLTOVF_TRAP 1
  43. #define FPE_FLTUND_TRAP 1
  44. #define FPE_FLTDIV_TRAP 1
  45. #define FPE_FLTINEX_TRAP 1
  46.  
  47.     /*    PRIVATE CONSTANTS    */
  48.  
  49. #define INTEGER_BIAS       31
  50. #define    SINGLE_BIAS      127
  51. #define DOUBLE_BIAS     1023
  52. #define EXTENDED_BIAS    16383
  53.  
  54.     /* PRIVATE TYPES    */
  55.  
  56. #ifdef DEBUG
  57. #define PRIVATE
  58. #else
  59. #define PRIVATE static
  60. #endif
  61.  
  62. #define    DOUBLE_E(n) (n & 0xfffe) /* More significant word of double. */
  63. #define DOUBLE_F(n) (1+DOUBLE_E(n)) /* Less significant word of double. */
  64. #define    EXTENDED_E(n) (n & 0xfffc) /* Sign/exponent word of extended. */
  65. #define EXTENDED_F(n) (1+EXTENDED_E(n)) /* More significant word of extended significand. */
  66. #define EXTENDED_FLOW(n) (2+EXTENDED_E(n)) /* Less significant word of extended significand. */
  67. #define EXTENDED_U(n) (3+EXTENDED_E(n)) /* Unused word of extended. */
  68.  
  69. typedef
  70.     struct
  71.     {
  72.     int sign ;
  73.     enum fp_class_type fpclass ;
  74.     int    exponent ;        /* Unbiased exponent. */
  75.     unsigned significand[3] ;    /* Third word is round and sticky. */
  76.     }
  77.     unpacked ;
  78.  
  79.     /* PRIVATE GLOBAL VARIABLES */
  80.  
  81. enum fp_direction_type fp_direction ;    /* Current rounding direction. */
  82. enum fp_precision_type fp_precision ;    /* Current extended rounding precision. */
  83.  
  84. unsigned    _fp_current_exceptions ; /* Current floating-point exceptions. */
  85.  
  86. struct fpu    * _fp_current_pfregs ;        /* Current pointer to stored f registers. */
  87.  
  88. void    (* _fp_current_read_freg) () ;    /* Routine to use to read f registers. */
  89. void    (* _fp_current_write_freg) () ;    /* Routine to use to write f registers. */
  90.  
  91. int        fptrapcode ;        /* Last code for fp trap. */
  92. char        *fptrapaddr ;        /* Last addr for fp trap. */
  93. enum seg_rw    fptraprw ;        /* Last fp fault read/write flag */
  94.  
  95.     /* PRIVATE FUNCTIONS */
  96.  
  97.     /* pfreg routines use "physical" FPU registers. */
  98.  
  99. extern void _fp_read_pfreg ( /* pf, n */ ) ;
  100.  
  101. /*    FPU_REGS_TYPE *pf        /* Where to put current %fn. */
  102. /*    unsigned n ;            /* Want to read register n. */
  103.  
  104. extern void _fp_write_pfreg ( /* pf, n */ ) ;
  105.  
  106. /*    FPU_REGS_TYPE *pf        /* Where to get new %fn. */
  107. /*    unsigned n ;            /* Want to read register n. */
  108.  
  109.     /* vfreg routines use "virtual" FPU registers at *_fp_current_pfregs. */
  110.  
  111. extern void _fp_read_vfreg ( /* pf, n */ ) ;
  112.  
  113. /*    FPU_REGS_TYPE *pf        /* Where to put current %fn. */
  114. /*    unsigned n ;            /* Want to read register n. */
  115.  
  116. extern void _fp_write_vfreg ( /* pf, n */ ) ;
  117.  
  118. /*    FPU_REGS_TYPE *pf        /* Where to get new %fn. */
  119. /*    unsigned n ;            /* Want to read register n. */
  120.  
  121. extern enum ftt_type
  122. _fp_iu_simulator( /* pinst, pregs, pwindow, pfpu */ ) ;
  123. /*    fp_inst_type    pinst;    /* FPU instruction to simulate. */
  124. /*    struct regs    *pregs;    /* Pointer to PCB image of registers. */
  125. /*    struct window    *pwindow;/* Pointer to locals and ins. */
  126. /*    struct fpu    *pfpu;    /* Pointer to FPU register block. */
  127.  
  128. extern void _fp_unpack ( /* pu, n, type */ ) ;
  129. /*    unpacked    *pu ;    /* unpacked result */
  130. /*    unsigned    n ;    /* register where data starts */
  131. /*    fp_op_type    type ;    /* type of datum */
  132.  
  133. extern void _fp_pack ( /* pu, n, type */) ;
  134. /*    unpacked    *pu ;    /* unpacked result */
  135. /*    unsigned    n ;    /* register where data starts */
  136. /*    fp_op_type    type ;    /* type of datum */
  137.  
  138. extern void _fp_unpack_word ( /* pu, n, type */ ) ;
  139. /*    unsigned    *pu ;    /* unpacked result */
  140. /*    unsigned    n ;    /* register where data starts */
  141.  
  142. extern void _fp_pack_word ( /* pu, n, type */) ;
  143. /*    unsigned    *pu ;    /* unpacked result */
  144. /*    unsigned    n ;    /* register where data starts */
  145.  
  146. extern void fpu_normalize (/* pu */) ;
  147. /*    unpacked    *pu ;    /* unpacked operand and result */
  148.  
  149. extern void fpu_rightshift (/* pu, n */) ;
  150. /*    unpacked *pu ; unsigned n ;    */
  151. /*    Right shift significand sticky by n bits. */
  152.  
  153. extern void fpu_set_exception(/* ex */) ;
  154. /*    enum fp_exception_type ex ;    /* exception to be set in curexcep */
  155.  
  156. extern void fpu_error_nan(/* pu */) ;
  157. /*    unpacked *pu ;             /* Set invalid exception and error nan in *pu */
  158.  
  159. extern void unpacksingle (/* pu, x */) ;
  160. /*    unpacked    *pu;    /* packed result */
  161. /*    single_type    x;    /* packed single */
  162.  
  163. extern void unpackdouble (/* pu, x, y */) ;
  164. /*    unpacked    *pu;    /* unpacked result */
  165. /*    double_type    x;    /* packed double */
  166. /*    unsigned    y;    */
  167.  
  168. extern void _fp_product ( /* x, y, z */ ) ;
  169. /*
  170. unsig x, y;
  171. unsigned z[2] ;
  172.  
  173. /*    Computes product x * y into *z[2] */
  174.  
  175. extern enum fcc_type _fp_compare (/* px, py */) ;
  176.  
  177. extern void _fp_add(/* px, py, pz */) ;
  178. extern void _fp_sub(/* px, py, pz */) ;
  179. extern void _fp_mul(/* px, py, pz */) ;
  180. extern void _fp_div(/* px, py, pz */) ;
  181. extern void _fp_sqrt(/* px, pz */) ;
  182.  
  183. extern enum ftt_type    _fp_write_word ( /* caddr_t, value */ ) ;
  184. extern enum ftt_type    _fp_read_word ( /* caddr_t, pvalue */ ) ;
  185. extern enum ftt_type    read_iureg ( /* n, pregs, pwindow, pvalue */ );
  186. #endif /* lint */
  187.